package com.timoon.webcomponent.utility.form.form1;

import java.util.Arrays;
import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.ImageButton;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.PackageResourceReference;

import com.googlecode.wicket.jquery.ui.form.RadioChoice;

/**
 *<p></p>
 *<p></p>
 *<p>Copyright:Copyright(c)2013.4.1</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */
public class Form1Panel extends Panel {

	private TextField<String> text;
	
	private Class<? extends WebPage> targetPage;
	
	public Form1Panel(String id,Class<? extends WebPage> targetPage) {
		super(id);
		// TODO Auto-generated constructor stub
		
		this.targetPage=targetPage;
		
		renderPanel();
	}

	private void renderPanel() {
		// TODO Auto-generated method stub
		
		renderForm();
		
	}

	private void renderForm() {
		// TODO Auto-generated method stub
		
		Form form=new Form("wk_form");
		add(form);
		
		renderSearch(form);
		
	}

	private void renderSearch(Form form) {
		// TODO Auto-generated method stub
		
		text=new TextField<String>("wk_text",new Model<String>());
		text.setOutputMarkupId(true);
		form.add(text);
		
		ImageButton button=new ImageButton("wk_btn", new PackageResourceReference(this.getClass(),"searchbtn.png")){
			@Override
			public void onSubmit() {
				// TODO Auto-generated method stub
				super.onSubmit();
				
				PageParameters pageParameters=new PageParameters();
				pageParameters.set("searchInfo", text.getModelObject());
				
				this.setResponsePage(targetPage,pageParameters);
			}
		};
		form.add(button);
	}

}
